package keter.sec.springsec;

import com.jfinal.plugin.activerecord.Db;
import io.undertow.Undertow.Builder;
import io.undertow.UndertowOptions;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;

/**
 * Created by gkatzioura on 9/2/16.
        */
    @SpringBootApplication
    @EnableAutoConfiguration
    public class SecureApp implements UndertowBuilderCustomizer {

    @Bean
    UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
        UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
        factory.addBuilderCustomizers(
                builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
        return factory;
    }

    public static void main(String[] args) {
        SpringApplication.run(SecureApp.class, args);
        Db.find("select 1");
    }

    @Override
    public void customize( Builder builder) {
//        builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true);
    }
}
